<%@page import="contract.ContractDAO"%>
<%@page import="contract.ContractDTO"%>
<%@page import="common.SerialDTO"%>
<%@page import="common.SerialDAO"%>
<%@page import="approval.ApprovalDAO"%>
<%@page import="java.net.URLDecoder"%>
<%@page import="org.json.simple.parser.JSONParser"%>
<%@page import="org.json.simple.JSONArray"%>
<%@page import="org.json.simple.JSONObject"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> </title>
</head>
<body>
<jsp:useBean id="dto" class="approval.ApprovalDTO" />
<jsp:setProperty property="*" name="dto"/>
<%
String mid = (String)session.getAttribute("mid");

ApprovalDAO dao = new ApprovalDAO();
dao.setDto(dto);

//결재번호 자동 채번 ============ //
SerialDTO sdto = new SerialDTO();
sdto.setTblName("APPROVAL");
sdto.setColName("ap_no");
sdto.setGubun("A");

SerialDAO sdao = new SerialDAO();
sdao.setDto(sdto);
String ap_no = sdao.serialReturn();
System.out.println("ap_no = "+ap_no);
dto.setAp_no(ap_no);
//=============================== //

// session값으로 등록자/수정자 세팅 ============ //
dto.setRg_pp((String)session.getAttribute("mid"));
dto.setMd_pp((String)session.getAttribute("mid"));
//============================================== //
int yn = dao.insert();

ContractDTO cont = new ContractDTO();
cont.setAp_no(ap_no);
cont.setCt_no(dto.getCt_no());
cont.setCt_ing("02");
ContractDAO condao = new ContractDAO();
condao.setCont(cont);
boolean flag = condao.appUp();
System.out.println(flag);
%>
</body>
</html>